package com.example.controller;

import com.example.pojo.Hospital;
import com.example.service.HospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hospital")
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;
    /**
     * 获取所有医院信息
     * */
    @GetMapping("/list")
    public Map<String, Object> listHospitals() {
        List<Hospital> hospitals = hospitalService.listAllHospitals();
        int total = hospitalService.getTotalHospitalCount();
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("total", total);
        resultMap.put("data", hospitals);
        return resultMap;
    }
}
